
//
//  HYLButton.m
//  事件的产生与传递应用二
//
//  Created by hyl on 16/6/19.
//  Copyright © 2016年 hyl. All rights reserved.
//

#import "HYLButton.h"

@interface HYLButton ()

@end

@implementation HYLButton

-(void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    UITouch *touch=[touches anyObject];
    CGPoint curP=[touch locationInView:self];
    CGPoint preP=[touch precisePreviousLocationInView:self];
    
    CGFloat offX=curP.x-preP.x;
    CGFloat offY=curP.y-preP.y;
    
    self.transform=CGAffineTransformTranslate(self.transform, offX, offY);
    
}

-(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event{
    CGPoint p=[self convertPoint:point toView:self.btn];
    if ([self.btn pointInside:p withEvent:event]) {
        return self.btn;
    }else{
        return [super hitTest:point withEvent:event];
    }
//    return [super hitTest:point withEvent:event];
}
@end
